import { getWeather,getGeographicalLocation } from '../service/home'

export default {
    async getWeatherInfo({ commit }, args) {
        const wearther = await getWeather(args);
        commit('updateWeather', { wearther })
    },
    async getPostion({ commit }) {
        const postion = await getGeographicalLocation();
        commit('updatePostion', { postion })
    },
    async getWeatherInfoByPostion({ state, dispatch }){
        await dispatch('getPostion');
        const { CityCode } = state.postion;
        dispatch('getWeatherInfo',{ id: CityCode });
    },
    async initCitys({ state, dispatch, commit }){
        if(!state.postion.id){
            await dispatch('getPostion');
        }
        commit('updateCityList');
    }
}